<template>
	<view id="app">
		<uv-sticky bgColor="#fff">
			<uv-tabs :list="statusList":activeStyle="{color: '#145cfe',transform: 'scale(1.05)'}":inactiveStyle="{color: '#000',transform: 'scale(1)'}"
			keyName="name" :current="current" @change="change" lineColor="#145cfe" lineWidth="100rpx">
			</uv-tabs>
		</uv-sticky>
		<view class="container fdc">		
			<view class="df fdc mtb10 bgw " v-for="(item,index) in list" :key="index">
				<view class="rows ptb20 plr20 bdb1s brcce" @click="handle('member/order/detail?id='+item.id)">
					<view class="c000 f28 mr20">{{item.order_sn}}</view>
					<view class="f1 df ptb10">
						<view class="f22 plr15 bgwaring cw br15" v-if="item.order_type == 3 ">团购</view>
						<view class="f22 plr15 bgwaring cw br15" v-if="item.order_type == 2 ">拼团</view>
					</view>
					<view class="w100 f28 c666" v-if="item.order_status == 1">待分享</view>
					<view class="w100 f28 c666" v-if="item.order_status == 2">待核销</view>
					<view class="w100 f28 c666" v-if="item.order_status == 3">待退款</view>
					<view class="w100 f28 c666" v-if="item.order_status == 4">已退款</view>
					<view class="w100 f28 c666" v-if="item.order_status == 5">已完成</view>
				</view>
				<view class="df ptb20 plr15 bdb1s brcce"  @click="handle('member/order/detail?id='+item.id)">
					<view class="w300 h180 br15 courseImg"><image :src="item.course_thumb"></image></view>
					<view class="f1 ml15 df fdc">
						<view class="h120">
							<view class="f32 c000 fw4 th2d">{{item.course_title}}</view>
							<view class="f26 c666  mt15">
								开营:{{item.start_time}}至{{item.end_time}}
							</view>
						</view>
						
						<view class="df aic cdebug f32 fw8">¥{{item.order_price}}</view>
					</view>
				</view>
				<view class="df aic jcr ptb20">
					<view class="bd1s brcce br15 plr20 ptb10 mlr10 f24 c666" v-if="item.order_status == 1" @click="handle('member/order/share?id='+item.id)">分享</view>
					<view class="bd1s brcce br15 plr20 ptb10 mlr10 f24 c666" v-if="item.order_status == 2" @click="handle('member/order/qrcode?id='+item.id)">查看券码</view>
					<view class="bd1s brcce br15 plr20 ptb10 mlr10 f24 c666" v-if="item.order_status == 5 && item.is_comment == 0" @click="handle('member/order/comment?id='+item.id)">评价</view>
					<view class="bd1s brcce br15 plr20 ptb10 mlr10 f24 c666" v-if="item.order_status < 3 && item.is_refund == 0 " @click="handle('member/order/refund?id='+item.id)">退款</view>
				</view>
			</view>
			<uv-load-more status="nomore" v-if="!more"/>
		</view>
	</view>
</template>

<script>
	let that;
	export default {
		data(){
			return {
				statusList: [{id:0,name: '全部'}, {id:1,name: '待接单'}, {id:2,name: '待施工'},{id:3,name: '已完成'},{id:4,name: '待评价'},{id:5,name:'已取消'}],
				current: 0,
				courseimg:this.util.config.host+"/static/images/1.jpg",
				list:[],
				page:1,
				more:true,
				nodata:true,
			}
		},
		onLoad(e){
			console.log('Load');
			that = this;
			if(e.type){
				this.current = e.type;
			}
			
		},
		onShow(){
			console.log('show');
			that.reLoad()
		},
		onReachBottom(){
			if(that.more == false){
				return false;
			}
			that.getList();
		},
		methods: {
			handle(e){
				uni.navigateTo({
					url:"/pages/"+e,
				})
			},
			reLoad() {
				// 格式化页码
				that.page = 1
				that.list = []
				that.more = true
				that.nodata = true
				// 获取产品列表
				that.getList();
			},
			change(index) {
				console.log(index);
				this.current = index.id;
				console.log(this.current);
				this.reLoad();
	
			},
			getList:function(){
				let page = that.page
				let type = that.current;
				return ;
				that.request({
					url:'/api/order/index',
					data:{
						type:type,
						page:page
					},
					success:function(res){
					if(res.code == 200){
						if(page == 1){
							that.list = res.data;
							if(res.data.length == 0){
								that.nodata=false;
							}
						}else{
							that.list.push(...res.data)
						}
						that.more = res.data.length < 10 ? false : true;
						that.page=page+1;
					}
				}})
			},
		}
	}
</script>

<style>

</style>
